package com.sghd.candy.module.bag.service;

import com.sghd.candy.module.bag.manager.PlayerBag;
import com.sghd.candy.module.bag.manager.PlayerBagManager;
import com.sghd.candy.module.player.manager.Player;
import com.sghd.common.ramcache.aop.AutoLocked;
import com.sghd.common.ramcache.aop.IsLocked;
import com.sghd.pojo.candy.bag.enums.PropType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Allen
 * @date 2018/12/26
 */
@Service
public class PlayerBagService {
    @Autowired
    private PlayerBagManager playerBagManager;

    public PlayerBag getPlayerBag(long playerId) {
        return playerBagManager.getPlayerBag(playerId);
    }
    @AutoLocked
    public void change(@IsLocked Player player, PropType propType, long changeNum) {
        PlayerBag playerBag = playerBagManager.getPlayerBag(player.getPlayerId());
        playerBagManager.change(playerBag, propType, changeNum);
    }
}
